package com.example.demo.service;

import com.example.demo.dao.UserDao;
import com.example.demo.entity.User;
import com.example.demo.pojo.TokenManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务层的具体实现 业务逻辑的具体实现
 * 可能有多个Dao 还可能需要处理 事务
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }

    @Override
    public void getCode(int codeType) {
        //先生成一个验证码

        //调用邮箱的发送链接

        //存到缓存中

        //返回结果

    }

    @Override
    public User registerAndLogin(String userName, String userPwd, String vCode) {

        //先判断用户是否已经注册了
        User user = userDao.findUserByUserName(userName);
        if (user == null) {
            return null;
        }

        return null;

    }

    @Override
    public User loginByPassword(String userName, String userPwd) {
        return null;
    }

    @Override
    public User loginByVCode(String userName, String vCode) {
        return null;
    }

    @Override
    public int logout() {
        return 0;
    }

    @Override
    public User update(User user) {
        return null;
    }

}
